package com.gxar.quick.ar.server.base.model.protocol.editor.unity;

import com.gxar.common.utils.JacksonUtils;
import com.gxar.common.utils.StringUtils;
import com.gxar.quick.ar.server.base.common.enums.protocol.ArUnityEditorIdentifyTypeEnum;
import com.gxar.quick.ar.server.base.model.protocol.ArSizeModel;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * Unity编辑器识别图信息
 *
 * <a href="https://git.gxar.com/product/product-pc-rebuild-editor-tool-u3d/-/tree/feat-antpctool-document/Documents">点云配置工具面板介绍</a>
 *
 * @author zxh
 * @version 1.0
 * @created 2024/01/02.
 */
@Data
@Slf4j
public class UnityEditorArIdentifyModel {

    private String version;

    private ArUnityEditorIdentifyTypeEnum type;

    private Double pixelPerUnit;

    private Double unitFactor;

    private String url;

    private ArSizeModel size;

    public static UnityEditorArIdentifyModel from(String inputConfig){
        if (StringUtils.isEmpty(inputConfig) || !inputConfig.startsWith("{") || !inputConfig.endsWith("}")) {
            log.warn("build UnityEditorArIdentifyModel error! inputConfig: {}", inputConfig);
            return null;
        }

        return JacksonUtils.parseObject(inputConfig, UnityEditorArIdentifyModel.class);
    }
}
